//
//  FileUploadViewController.m
//  HRJiWei
//
//  Created by zsj1992 on 16/12/14.
//  Copyright © 2016年 bjhj. All rights reserved.
//

#import "FileUploadViewController.h"
#import "TZImagePickerController.h"
@interface FileUploadViewController ()<TZImagePickerControllerDelegate>
@property (weak, nonatomic) IBOutlet UIButton *btnAdd;

@end

@implementation FileUploadViewController

- (IBAction)upload:(id)sender {
    
    
    self.report.reportStyle = [Tool isBlankString:self.report.reportStyle]?@"":self.report.reportStyle;
    
    
    
    NSMutableDictionary * parameterDic = [NSMutableDictionary dictionary];
    [parameterDic setObject:[Tool isBlankString:self.report.reportStyle]?@"":self.report.reportStyle  forKey:@"reportStyle"];
    [parameterDic setObject:[Tool isBlankString:self.report.reportTitle]?@"":self.report.reportStyle forKey:@"reportTitle"];
    [parameterDic setObject:[Tool isBlankString:self.report.categoryId]?@"":self.report.reportStyle forKey:@"categoryId"];
    [parameterDic setObject:[Tool isBlankString:self.report.categoryName]?@"":self.report.reportStyle forKey:@"categoryName"];
    [parameterDic setObject:[Tool isBlankString:self.report.reportContent]?@"":self.report.reportStyle forKey:@"reportContent"];
    [parameterDic setObject:[Tool isBlankString:self.report.toName]?@"":self.report.reportStyle forKey:@"toName"];
    [parameterDic setObject:[Tool isBlankString:self.report.toCompany]?@"":self.report.reportStyle forKey:@"toCompany"];
    [parameterDic setObject:[Tool isBlankString:self.report.toSex]?@"":self.report.reportStyle forKey:@"toSex"];
    [parameterDic setObject:[Tool isBlankString:self.report.toPosition]?@"":self.report.reportStyle forKey:@"toPosition"];
    [parameterDic setObject:[Tool isBlankString:self.report.toPolitical]?@"":self.report.reportStyle forKey:@"toPolitical"];
    [parameterDic setObject:[Tool isBlankString:self.report.toArea]?@"":self.report.reportStyle forKey:@"toArea"];
    [parameterDic setObject:[Tool isBlankString:self.report.toAddress]?@"":self.report.reportStyle forKey:@"toAddress"];
    [parameterDic setObject:[Tool isBlankString:self.report.toLevel]?@"":self.report.reportStyle forKey:@"toLevel"];
    [parameterDic setObject:[Tool isBlankString:self.report.toName]?@"":self.report.reportStyle forKey:@"fromName"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromSex]?@"":self.report.reportStyle forKey:@"fromSex"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromPolitical]?@"":self.report.reportStyle forKey:@"fromPolitical"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromNational]?@"":self.report.reportStyle forKey:@"fromNational"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromMobile]?@"":self.report.reportStyle forKey:@"fromMobile"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromIdno]?@"":self.report.reportStyle forKey:@"fromIdno"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromArea]?@"":self.report.reportStyle forKey:@"fromArea"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromAddress]?@"":self.report.reportStyle forKey:@"fromAddress"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromPost]?@"":self.report.reportStyle forKey:@"fromPost"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromCompany]?@"":self.report.reportStyle forKey:@"fromCompany"];
    [parameterDic setObject:[Tool isBlankString:self.report.fromPosition]?@"":self.report.reportStyle forKey:@"fromPosition"];
    [parameterDic setObject:[Tool isBlankString:files]?@"":files forKey:@"files"];

    
    
    
}

NSString * files;


- (IBAction)Add:(id)sender {
    
    
    TZImagePickerController * imgPicker = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
    
    [self presentViewController:imgPicker animated:YES completion:nil];
    
    
}
- (IBAction)back:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{

    
    
    
    
    
    
    
    for (UIImage * image in photos) {
        
       NSData *imageData = UIImagePNGRepresentation(image);

        [NetWork typePictureYesPOST:uploadFile parameters:nil withPicureData:imageData withKey:@"uploadFile" finish:^(NSData *data, NSError *error) {
            
            NSDictionary * dataDic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil];
            NSLog(@"%@",dataDic);
            
            
            NSInteger code =[dataDic[@"code"] integerValue];
            
            if (code==1) {
                
                [self.btnAdd setImage:image forState:(UIControlStateNormal)];
                
                files = dataDic[@"result"][@"filePath"];
                
            }

        }];
        
    }
    

}


- (void)viewDidLoad {
    [super viewDidLoad];

    
    


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
